import 'package:bt_dsp_88/model/model.dart';
import 'package:flutter/material.dart';

import '../../tool/assets.dart';

abstract class SectionView extends StatefulWidget {
  String title;
  List<ChannelModel> ch_list;
  SectionView({
    super.key,
    required this.title,
    required this.ch_list,
  });

  @override
  State<SectionView> createState();
}

///使用泛型
abstract class SectionViewState<T extends SectionView> extends State<T> {
  ///子类需要实现这个方法来返回header的内容
  Widget buildHeader(BuildContext context);

  ///子类需要实现这个方法来返回具体的页面内容
  Widget buildContent(BuildContext context);

  @override
  Widget build(BuildContext context) {
    double screenHeight = MediaQuery.of(context).size.height;

    return Column(
      children: [
        SizedBox(
          height: 30.0 * GlobalConfig.scaleH,
          child: Stack(
            children: [
              Positioned(
                  left: 0,
                  right: 0,
                  top: 15 * GlobalConfig.scaleH,
                  child: Container(color: Colors.black, height: 1)),
              Center(
                  child: Text(
                widget.title,
                textAlign: TextAlign.center,
                style: const TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                    color: Colors.black,
                    backgroundColor: Color_bg_view),
              )),
              buildHeader(context),
            ],
          ),
        ),
        // SizedBox(height: screenHeight == 667 ? 0 : 0 * GlobalConfig.scaleH),
        buildContent(context),
        // SizedBox(height: screenHeight == 667 ? 0 : 0 * GlobalConfig.scaleH),
      ],
    );
  }
}
